import { Component, OnInit } from '@angular/core';
import { ApiService } from "@core/services/http/api.service";
import {ActivatedRoute, Params }  from "@angular/router";
import {ApesMessageService} from "@shared/apes/message";

@Component({
  selector: 'apes-sheet-metal-detail',
  templateUrl: './sheet-metal-detail.component.html',
  styleUrls: ['./sheet-metal-detail.component.scss']
})
export class SheetMetalDetailComponent implements OnInit {
  reportList: any[];
  bodyData = {};
  footList: any[];

  nfxxList: any[];

  jjcdhNum: number; //2000774480


  constructor(private apiService: ApiService,
     private routeInfo: ActivatedRoute,
              private msg: ApesMessageService) { }

  ngOnInit() {

    this.routeInfo.params.subscribe((params: Params) => this.jjcdhNum = params["data"])

    this.getTablesData();
    this.reportList = this.getFullData();

    this.getTablData();
    this.getTfootData();

  }


  getTablesData() {
    let data = { 'interfaceMethod': 'ipmBPforAppService.getXQBPLB', 'pdata': { 'JJCDH': this.jjcdhNum } };
    this.apiService.post('report.interface', { 'body': JSON.stringify(data) }).subscribe(
      (resultData) => {
        const result = JSON.parse(resultData);
        if (result.success) {
          if (result.obj.length !== 0) {
            let data = JSON.parse(result.obj)
            this.bodyData = data;
          }
        } else {
          this.msg.info(result.msg);
        }
      });
  }

  getTablData() {
    let data = { 'interfaceMethod': 'ipmBPforAppService.getXQSgjdxx', 'pdata': { 'JJCDH': this.jjcdhNum } };
    this.apiService.post('report.interface', { 'body': JSON.stringify(data) }).subscribe(
      (resultData) => {
        const result = JSON.parse(resultData);
        if (result.success) {
          if (result.obj.length !== 0) {
            let data = JSON.parse(result.obj)
            this.footList = data;
          }
        } else {
          this.msg.info(result.msg);
        }
      });
  }

  getTfootData() {
    let data = { 'interfaceMethod': 'ipmBPforAppService.getXQNfxx', 'pdata': { 'JJCDH': this.jjcdhNum } };
    this.apiService.post('report.interface', { 'body': JSON.stringify(data) }).subscribe(
      (resultData) => {
        const result = JSON.parse(resultData);
        if (result.success) {
          if (result.obj.length !== 0) {
          let data = JSON.parse(result.obj)
          this.nfxxList = data;
        }
        } else {
          this.msg.info(result.msg);
        }
      });
  }

  getFullData() {
    return [
      {
        headerTop: "车辆信息",
        bodyData: [
          { lable: '车牌号码', feild: 'CPHM' },
          { lable: '品牌', feild: 'QCCPMC' }
        ],
      },
      {
        headerTop: "接车信息",
        bodyData: [
          { lable: '内协门店', feild: 'NXMDMC' },
          { lable: '门店接车人', feild: 'MDJIECR' },
          { lable: '门店接车时间', feild: 'NXMDJCRQ_SJ' },
          { lable: '内协时间', feild: 'NXRQ_SJ' },
          { lable: '接车基地', feild: 'JCMDMC' },
          { lable: '基地接车人', feild: 'JDJIECR' },
          { lable: '基地接车时间', feild: 'JDJCRQ_SJ' },
          { lable: '预计交车时间', feild: 'YJJCRQ_SJ' }

        ],
      },
      {
        headerTop: "送修信息",
        bodyData: [
          { lable: '送修司机', feild: 'SXSJMC' },
          { lable: '完成送修时间', feild: 'SXWXRQ_SJ' }
        ],
      },
      {
        headerTop: "还车信息",
        bodyData: [
          { lable: '内协归还门店', feild: 'NXMDMC' },
          { lable: '归还时间', feild: 'JDGHRQ_SJ' },
          { lable: '交车门店', feild: 'JCMDMC' },
          { lable: '交车时间', feild: 'JCRQ_SJ' },
          { lable: 'T+留存', feild: 'TLC' }
        ],
      },
      {
        headerTop: "维修信息",
        bodyData: [
          { lable: '维修类型', feild: 'WXLX' },
          { lable: '幅数', feild: 'FS' },
          { lable: '喷漆部位', feild: 'PQBW' },
          { lable: '钣金部位', feild: 'BJBW' },
          { lable: '商品列表', feild: 'SPMC' }
        ],
      },
      {
        headerTop: "其他信息",
        bodyData: [
          { lable: '定损全部完成时间', feild: 'DSWCRQ_SJ' },
          { lable: '配件全部到货时间', feild: 'PJDHRQ_SJ' },
          { lable: '进入施工端时间', feild: 'JRSGDRQ_SJ' }
        ],
      },
      {
        headerTop: "施工进度信息",
        bodyData: [
          { lable: '是否已调色', feild: 'SFYTS' },
          { lable: '调色完成时间', feild: 'TSWCRQ_SJ' },
          { lable: '调色人', feild: 'TSR' }
        ],
      },
    ];
  }

  footData = [
    { lable: '步骤', feild: 'BZ' },
    { lable: '施工时长（分钟）', feild: 'SGSC' },
    { lable: '施工人', feild: 'SGR' },
    { lable: '操作人', feild: 'CZY' },
    { lable: '操作', feild: 'CZ' },
    { lable: '时间', feild: 'SGRQ_SJ' }
  ];

  nfxxData = [
    { lable: '返工步骤', feild: 'FGBZ' },
    { lable: '原因', feild: 'FGYY' },
    { lable: '施工人', feild: 'SGR' },
    { lable: '操作人', feild: 'CZY' },
    { lable: '时间', feild: 'FGRQ_SJ' }
  ];

}

